package educar.inscripcion;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JOptionPane;

import educar.Carrera.CarreraController;
import educar.materia.MateriaController;

public class InscripMateriaMediador implements ActionListener {

	private InscripMateriaVentana view = new InscripMateriaVentana();
		
	public InscripMateriaMediador(){
		view.setVisible(true);
		view.addActionListener(this);
	}
				
	public void actionPerformed(ActionEvent e) {
		Object obj = e.getSource();
		if(obj instanceof JButton)
		  ListenerEvent(((JButton) obj).getLabel());
	}
		
	private void ListenerEvent(String event){
	if(event.compareTo("LISTAR")==0){
			if (!CarreraController.existe(view.getCodigo())){
				JOptionPane.showMessageDialog(null, "Dicha carrera no existe.");
			}else {
				InscripcionMateriaMediador med = new InscripcionMateriaMediador (view.getCodigo());
				view.limpiar();
			}
		}
		if(event.compareTo("CERRAR")==0){
			view.dispose();
		}
	}
	
}
